﻿using Microsoft.EntityFrameworkCore;
using ShuiLing.Application.Abstractions.Data;

namespace ShuiLing.Persistence;

public sealed class ApplicationDbContext : DbContext, IApplicationDbContext
{
    public ApplicationDbContext(DbContextOptions options)
        : base(options)
    {
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder) =>
        modelBuilder.ApplyConfigurationsFromAssembly(AssemblyReference.Assembly);

    public int AppSaveChanges()
    {
        return SaveChanges();
    }

    public async Task<int> AppSaveChangesAsync(CancellationToken cancellationToken = default)
    {
        return await SaveChangesAsync(cancellationToken);
    }
}
